package com.write.program.socket.message;

import com.alibaba.fastjson.JSON;

import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Endstart
 * Date: 2019-11-20
 * Time: 23:28
 */
public abstract class Message implements Serializable {
    protected String msg;

    public abstract int getType();

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public byte[] toBytes() {
        String ret = JSON.toJSONString(this) + "\n";
        return ret.getBytes();
    }


    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
